package file_1;

import java.io.File;
import java.util.Scanner;

public class FileDemo3 {
    public static void main(String[] args) {
        modifyFileName();
    }

    public static void modifyFileName() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入关键字：");
            String filename = sc.nextLine();
            File dir = new File(".");
            if (dir.isDirectory()) {
                File[] subs = dir.listFiles(f -> f.getName().contains(filename));
                for (File sub : subs) {
                    System.out.println(sub.getName());
                }
            }
        }
    }
}